package com.example.blog.ws.util;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.blog.mapper.UserMapper;
import com.example.blog.pojo.User;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

;
@Component
public class UserIdUtils {
    @Resource
    private UserMapper userMapper;
    //获取用户id
    public Integer getUserId(String userName){
        QueryWrapper<User> Wrapper = new QueryWrapper<>();
        QueryWrapper<User> eq = Wrapper.eq("username",userName);
        User user = userMapper.selectOne(eq);
        return user.getId();
    }
}
